#include "stdio.h"
#include <string.h>

main()
{
	int t,n;
	char data[21];
	char out[21],shu[45];
	int i,j,k,p,tot,pt;

	scanf("%d",&t);
	for (i=1;i<=t;++i)
	{
		memset(data,0,sizeof(data));
		memset(out,0,sizeof(out));
		memset(shu,0,sizeof(shu));

		scanf("%d",&n);
		for (j=1;j<=n;++j)
			scanf("%d",&data[j]);
		p=0;
		for (j=1;j<=n;++j)
		{
			if (data[j]>data[j-1])
				for (k=1;k<=(data[j]-data[j-1]);++k)
					shu[++p]=1;
			shu[++p]=-1;
		}
		
		k=0;		
		for (j=1;j<=p;++j)
		{
			if (shu[j]==-1)
			{
				tot=-1;pt=j;
				while (tot<0)
				{
					--pt;
					tot+=shu[pt];
				}	
				out[++k]=(j+1-pt)/2;	
			}
		}
		for (j=1;j<k;++j) printf("%d ",out[j]);
		printf("%d\n",out[k]);
	}
}



